package com.zhiyan.say.dao;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.zhiyan.common.util.exception.DaoException;
import com.zhiyan.say.dao.mapper.ClassificationMapper;
import com.zhiyan.say.domain.entity.Classification;

@Repository
public class ClassificationDao {
	@Autowired
	private ClassificationMapper classificationMapper;
	
	/**
	 * 新增
	 * @param classification
	 */
	public void add(Classification classification){
		try {
			classificationMapper.add(classification);
		} catch (Exception e) {
			throw new DaoException(e.getMessage(), e);
		}
	}
	
	/**
	 * 更新
	 * @param classification
	 */
	public void update(Classification classification){
		try {
			classificationMapper.update(classification);
		} catch (Exception e) {
			throw new DaoException(e.getMessage(), e);
		}
	}
	
	/**
	 * 条件查询
	 * @param map
	 * @return
	 */
	public List<Classification> query(Map<String, Object> map) {
		try {
			List<Classification> list = classificationMapper.query(map);
			return list;
		} catch (Exception e) {
			throw new DaoException(e.getMessage(), e);
		}
	}

	/**
	 * 批量更改状态
	 * @param status	状态
	 * @param idList	id列表
	 */
	public void reStatus(String status, List<String> idList){
		try {
			classificationMapper.reStatus(status, idList);
		} catch (Exception e) {
			throw new DaoException(e.getMessage(), e);
		}
	}

}
